package com.newtouch.bxzs.business.statistics.controller;

import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.statistics.model.bo.*;
import com.newtouch.bxzs.business.statistics.model.vo.AchievementSummaryVO;
import com.newtouch.bxzs.business.statistics.model.vo.EstimateIncomeVO;
import com.newtouch.bxzs.business.statistics.model.vo.PersonalIncomeCompositionVO;
import com.newtouch.bxzs.business.statistics.service.PersonalIncomeService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 收入与预估收入Controller
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/13</td>
 * <td>tianshangzhu</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author tianshangzhu
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "收入与预估收入")
@RestController
@RequestMapping("/personalIncomeController")
@SuppressWarnings("unchecked")
public class IncomeController {
    /**
     * 静态变量：系统日志
     */
    private static final Log logger = LogFactory.getLog(IncomeController.class);

    @Autowired
    private PersonalIncomeService personalIncomeService;

    @ApiOperation(value = "查询个人收入")
    @PostMapping("/getPersonalIncome")
    @MyLog(systemFunctionName = "收入与预估收入",systemFunctionUrl = "/personalIncomeController/getPersonalIncome",userOperationType = 4,userOperationSummary = "查询个人收入")
    public BaseResponse<List<PersonalIncomeBO>> getPersonalIncome(@RequestBody AchievementSummaryVO incomeVO) {
        logger.info("查询个人收入");
        return RespGenerator.returnOK(personalIncomeService.getPersonalIncome(incomeVO));
    }

    @ApiOperation(value = "查询个人收入构成")
    @PostMapping("/getPersonalIncomeComposition")
    @MyLog(systemFunctionName = "收入与预估收入",systemFunctionUrl = "/personalIncomeController/getPersonalIncomeComposition",userOperationType = 4,userOperationSummary = "查询个人收入构成")
    public BaseResponse<List<PersonalIncomeCompositionBO>> getPersonalIncomeComposition(@RequestBody PersonalIncomeCompositionVO personalIncomeCompositionVO) {
        logger.info("查询个人收入构成");
        return RespGenerator.returnOK(personalIncomeService.getPersonalIncomeComposition(personalIncomeCompositionVO));
    }

    @ApiOperation(value = "收入明细")
    @PostMapping("/getPolicyIncomeDetail")
    @MyLog(systemFunctionName = "收入与预估收入",systemFunctionUrl = "/personalIncomeController/getPolicyIncomeDetail",userOperationType = 4,userOperationSummary = "查询个人收入明细")
    public BaseResponse<List<IncomePolicyDetailBO>> getPolicyIncomeDetail(@RequestBody PersonalIncomeCompositionVO personalIncomeCompositionVO) {
        logger.info("收入明细");
        return RespGenerator.returnOK(personalIncomeService.getPolicyIncomeDetail(personalIncomeCompositionVO));
    }

    @ApiOperation(value = "预估收入汇总")
    @PostMapping("/getEstimateIncomeSummary")
    @MyLog(systemFunctionName = "收入与预估收入",systemFunctionUrl = "/personalIncomeController/getEstimateIncomeSummary",userOperationType = 4,userOperationSummary = "查询预估收入汇总")
    public BaseResponse<List<EstimateIncomeBO>> getEstimateIncomeSummary() {
        logger.info("预估收入汇总");
        return RespGenerator.returnOK(personalIncomeService.getEstimateIncomeSummary(new EstimateIncomeVO()));
    }

    @ApiOperation(value = "预估收入明细")
    @PostMapping("/getEstimateIncomeDetail")
    @MyLog(systemFunctionName = "收入与预估收入",systemFunctionUrl = "/personalIncomeController/getEstimateIncomeDetail",userOperationType = 4,userOperationSummary = "查询预估收入明细")
    public BaseResponse<List<EstimateIncomeDetailBO>> getEstimateIncomeDetail(@RequestBody EstimateIncomeVO estimateIncomeVO) {
        logger.info("预估收入明细");
        return RespGenerator.returnOK(personalIncomeService.getEstimateIncomeDetail(estimateIncomeVO));
    }
}
